<template>
  <div class="dashboard-container">
    <common-view
      :table-prop="tableProp"
      module-name="userLog"
      :search="getLogList"
      :get-search-data="getSearchData"
    />

  </div>
</template>

<script>

import CommonView from '@/components/commonView/index.vue'
import { getLogList } from '@/api/log'
import { getAllUser } from '@/api/user'

import dayjs from 'dayjs'

export default {
  name: 'UserLog',
  components: { 'common-view': CommonView },
  data() {
    return {
      getLogList,
      userList: [],
      professionList: [],
      tableData: [],
      tableProp: [
        {
          prop: 'id',
          label: 'id'
        },
        {
          prop: 'handleUserId',
          label: '操作用户'
          // formatter: value => {
          //   const findUser = this.userList.find(item => value.handleUserId === item.id)
          //   return findUser ? findUser.nickName : '-'
          // }
        }, {
          prop: 'handleName',
          label: '操作名称'
        },
        {
          prop: 'osType',
          label: '操作系统'
        }, {
          prop: 'clientType',
          label: '客户端类型'
        }, {
          prop: 'createTime',
          label: '操作时间',
          formatter: value => {
            return dayjs(value.createTime).format('YYYY-MM-DD HH:mm:ss')
          }
        }
      ]
    }
  },
  mounted() {
    // 数据初始化
    this.init()
  },
  methods: {
    async init() {
      const [userList] = await Promise.all([
        getAllUser()
      ])
      this.userList = userList
    },
    // 查询条件转换
    getSearchData(formData) {
      const { handleName, handleUserName } = formData
      return {
        handleName, handleUserName
      }
    }
  }
}
</script>

<style lang="scss" scoped>
.dashboard {
  &-container {
    margin: 30px;
  }
}
</style>
